<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>记事本</title>
    <link href="css/mui.min.css" rel="stylesheet"/>
    <link href="css/MyShare.css" rel="stylesheet"/>
</head>
<body>
	<header class="mui-bar mui-bar-nav">
	    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
	    <h1 class="mui-title" id='title'>记事本</h1>
	</header>
	
	
	
	<div class="mui-content">
		<textarea rows=32 id='fileContent'></textarea>
	</div>
	
	
	
	<nav class="mui-bar mui-bar-tab">
	    <a class="mui-tab-item mui-action-back">
	        <span class="mui-tab-label">取消</span>
	    </a>
	    <a class="mui-tab-item">
	        <span class="mui-tab-label" id='fileSave'>保存</span>
	    </a>
	</nav>
</body>
</html>
<script src="js/mui.min.js"></script>
<script src="js/tools.js"></script>
<script type="text/javascript" charset="utf-8">
mui.init();
mui.plusReady(function(){
	//getWebCount(); 
	
	var c = plus.webview.currentWebview();
	filePath = c.filePath;
	//alert(c.filePath+"\r\n"+c.title);
	mui('#title')[0].innerText = c.title;
	getPathEntry(filePath,function(res){
		readFile(res,function(res){
			if(!res.error){
				mui('#fileContent')[0].innerText = res;
			}
		});

	});
	
	
	mui('#fileSave')[0].addEventListener('tap',function(){
		var content = mui('#fileContent')[0].value.trim();
		getPathEntry(filePath,function(res){
			fileWrite(res,content,function(res){
				if(res=='ok'){
					alert('保存成功！');
					plus.webview.close(plus.webview.currentWebview());					
				}else{
					alert(res);
				}
			});
		})
	});
})
</script>